{extend name="public:layout" /}

{block name="title"}
<title>
    {:site('siteName')}-充值审核
</title>
{/block}

{block name="css"}
<link href="__STATIC__/{$theme}/css/user.css" rel="stylesheet" type="text/css">
    <style type="text/css">
        .tips { cursor: pointer; }
    </style>
    {/block}

{block name="content"}
    <div class="layui-main">
        <div class="user-main">
            <div class="user-left">
                {include file="public:user" /}
            </div>
            <div class="user-right">
                <div class="layui-tab layui-tab-brief">
                    <ul class="layui-tab-title">
                        <li class="layui-this">
                            代理列表
                        </li>
                        <li>
                            <a href="{:url('index/agent/record')}">
                                充值记录
                            </a>
                        </li>
                    </ul>
                    <div class="layui-tab-content">
                        <form action="{:url('index/agent/index')}" class="layui-form" data-type="sync" method="post">
                            <div class="layui-form-item">
                                <label class="layui-form-label">
                                    搜索代理
                                </label>
                                <div class="layui-input-inline" style="width: 320px;">
                                    <input class="layui-input" lay-verify="required" name="field" placeholder="请输入用户名、姓名、手机号、QQ、微信搜索" type="text" value="{$field|default=''}">
                                    </input>
                                </div>
                                <div class="layui-input-inline">
                                    <button class="layui-btn layui-btn-primary" lay-submit="">
                                        <i class="layui-icon">
                                            
                                        </i>
                                    </button>
                                </div>
                            </div>
                        </form>
                        <table class="table">
                            <thead>
                                <tr>
                                    <th>
                                        用户名
                                    </th>
                                    <th>
                                        姓名
                                    </th>
                                    <th>
                                        手机号
                                    </th>
                                    <th>
                                        QQ/微信
                                    </th>
                                    <th>
                                        支付宝
                                    </th>
                                    <th>
                                        银行
                                    </th>
                                    <!-- <th>剩余{$currency}</th> -->
                                    <th>
                                        操作
                                    </th>
                                </tr>
                            </thead>
                            <tbody>
                                {volist name="agents" id="v"}
                                <tr>
                                    <td>
                                        {$v.username}
                                    </td>
                                    <td>
                                        {$v.realname}
                                    </td>
                                    <td>
                                        {$v.mobile}
                                    </td>
                                    <td>
                                        {$v.qq}/{$v.wechat}
                                    </td>
                                    <td>
                                        {$v.alipay}
                                    </td>
                                    <td>
                                        {$v.bank}
                                        <br>
                                            {$v.bank_card}
                                        </br>
                                    </td>
                                    <!-- <td>{$v.recharge}</td> -->
                                    <td>
                                        <button class="layui-btn layui-btn-mini layui-btn-main confirm-recharge" data-uid="{$v['id']}">
                                            充值
                                        </button>
                                    </td>
                                </tr>
                                {/volist}
                            </tbody>
                        </table>
                        <div class="page">
                            {$agents->render()}
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    {/block}

{block name="script"}
    <script type="text/javascript">
        layui.use(['form', 'layer'], function(){
			var $ = layui.jquery;
    		var layer = layui.layer;

    		$(".confirm-recharge").click(function() {
    			var uid = $(this).data('uid');
    			checkPwd(function(pwd){
	    			layer.prompt({
					  	title: '请输入充值金额，1元=1{$currency}',
					}, function(num, index, elem){
						if(!/^\+?[1-9][0-9]*$/.test(num)){
							layer.msg('请输入一个正整数');
							return;
						}
					  	$.post('{:url("index/user/recharge")}', {uid: uid,num:num,pwd:pwd}, function(res) {
			            	if(res.status == 1){
			            		layer.msg(res.msg, {
				                    time: 1000
				                }, function() {
				                	if(res.url){
				                		location.href = res.url;
				                	}else{
				                		location.reload();
				                	}
				                });
			            	}else{
			            		layer.msg(res.msg);
			            	}
			            },'json');
			            layer.close(index);
					});
    			});
		        return false;
		    });
   
		});
    </script>
{/block}
